#include "lineedit2.h"
#include "ui_lineedit2.h"

LineEdit2::LineEdit2(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LineEdit2)
{
    ui->setupUi(this);

    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
}

LineEdit2::~LineEdit2()
{
    delete ui;
}

void LineEdit2::on_lineEdit_textEdited(const QString &arg1)
{
    (void)arg1;
    compare();
}

void LineEdit2::on_lineEdit_2_textEdited(const QString &arg1)
{
    (void)arg1;
    compare();
}

void LineEdit2::compare()
{
    QString s1 = ui->lineEdit->text();
    QString s2 = ui->lineEdit_2->text();

    if (s1 == s2)
    {
        ui->label->setText("两次输入密码一致");
    }
    else
    {
        ui->label->setText("两次输入密码不一致");
    }
}

void LineEdit2::on_checkBox_clicked(bool checked)
{
    if (checked)
    {
        ui->lineEdit->setEchoMode(QLineEdit::Normal);
    }
    else
    {
        ui->lineEdit->setEchoMode(QLineEdit::Password);
    }
}

void LineEdit2::on_checkBox_2_clicked(bool checked)
{
    if (checked)
    {
        ui->lineEdit_2->setEchoMode(QLineEdit::Normal);
    }
    else
    {
        ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    }
}
